//
//  XMGNavigationController.m
//  喜马拉雅FM
//
//  Created by 王顺子 on 16/8/1.
//  Copyright © 2016年 小码哥. All rights reserved.
//

#import "XMGNavigationController.h"

@interface XMGNavigationController()<UIGestureRecognizerDelegate>

@end


@implementation XMGNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];

}

- (void)back {

    [self popViewControllerAnimated:YES];
  
}



/**
 *  当控制器, 拿到导航控制器(需要是这个子类), 进行压栈时, 都会调用这个方法
 *
 *  @param viewController 要压栈的控制器
 *  @param animated       动画
 */
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {

    if (self.childViewControllers.count > 0) {
        NSBundle *currentBundle = [NSBundle bundleForClass:[self class]];
        NSString *bundleName = [currentBundle.infoDictionary[@"CFBundleName"] stringByAppendingString:@".bundle"];
        NSString *path = [currentBundle pathForResource:@"navigationButtonReturn@3x.png" ofType:nil inDirectory:bundleName];
        UIImage *image = [UIImage imageWithContentsOfFile:path];
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:image style:0 target:self action:@selector(back)];
        viewController.hidesBottomBarWhenPushed = YES;
    }
    // 千万不要忘记写
    [super pushViewController:viewController animated:animated];

}

@end
